﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Modules.guide.actions {
    import Classes.*;
    import Classes.util.*;
    import Modules.guide.*;
    import com.zynga.skelly.util.*;

    public class GARefreshResources extends GuideAction {

        protected var m_itemNames:Array;
        protected var m_predicate:Function = null;
        protected var m_delaySeconds:Number = 0;

        public function GARefreshResources(){
            this.m_itemNames = [];
            super();
        }
        override public function createFromXml(_arg1:XML):Boolean{
            var _local2:XMLList = checkAndGetElement(_arg1, "refresh");
            if (!_local2){
                return (false);
            };
            var _local3:String = String(_local2.@itemNames);
            if (_local3.length > 0){
                this.m_itemNames = _local3.split(",");
            };
            var _local4:String = String(_local2.@predicateName);
            if (_local4.length > 0){
                this.m_predicate = GuideUtils[_local4];
            };
            this.m_delaySeconds = ((Number(_local2.@delay)) || (0));
            return (true);
        }
        override public function update(_arg1:Number):void{
            var delta:* = _arg1;
            super.update(delta);
            TimerUtil.callLater(Curry.curry(function (_arg1:Array, _arg2:Function):void{
                var _local4:*;
                var _local5:*;
                var _local3:* = [];
                if (_arg1.length > 0){
                    _local3 = Global.world.getObjectsByNames(_arg1);
                } else {
                    if (_arg2 != null){
                        _local3 = Global.world.getObjectsByPredicate(_arg2);
                    };
                };
                for each (_local4 in _local3) {
                    _local5 = (_local4 as MapResource);
                    if (_local5 != null){
                        _local5.setState(_local5.getState());
                        _local5.refreshArrow();
                    };
                };
            }, this.m_itemNames, this.m_predicate), (this.m_delaySeconds * 1000));
            removeState(this);
        }

    }
}//package Modules.guide.actions 
